import Router from "koa-router";

import { getArticlesValidator, articleIdValidator } from "../validator/article";
import {
  getArticles,
  getArticle,
  updateArticleStatus,
  deleteArticle,
  createArticle
} from "../controller/article";

const router = new Router();

// 获取所有文章
router.get("/articles", ...getArticlesValidator, getArticles);

// 获取单个文章
router.get("/articles/:id", ...articleIdValidator, getArticle);

// 更新文章状态
router.put("/articles/status/:id", ...articleIdValidator, updateArticleStatus);

// 删除文章
router.del("/articles/:id", ...articleIdValidator, deleteArticle);

// test 新增文章
router.post("/articles",createArticle)

export { router as default };
